/*
 * Testgen4JSemiAutomaticoView.java
 */
package testgen4jsemiautomatico;

import java.awt.Component;
import java.awt.Frame;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import javax.swing.DefaultListModel;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.tree.DefaultMutableTreeNode;
import org.jdom.Document;
import org.jdom.JDOMException;

/**
 * The application's main frame.
 */
public class Testgen4JSemiAutomaticoView extends FrameView {
DtoXMLCasoPrueba dtoCaso=new DtoXMLCasoPrueba();
HashSet<DtoXmlTree> dtoListClass=new HashSet<DtoXmlTree>();
    public Testgen4JSemiAutomaticoView(SingleFrameApplication app) {
        super(app);

        initComponents();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {

            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String) (evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer) (evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    //@SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        DefaultMutableTreeNode      root = new DefaultMutableTreeNode("ROOT");
        jTree1 = new javax.swing.JTree(root);
        jButton1 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextPane1 = new javax.swing.JTextPane();
        jLabel2 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jLabel4 = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();

        mainPanel.setName("mainPanel"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTree1.setName("jTree1"); // NOI18N
        jTree1.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
            public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
                jTree1ValueChanged(evt);
            }
        });
        jTree1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTree1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTree1);

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(testgen4jsemiautomatico.Testgen4JSemiAutomaticoApp.class).getContext().getResourceMap(Testgen4JSemiAutomaticoView.class);
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        jPanel1.setName("jPanel1"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(24, 24, 24)
                .add(jLabel1)
                .addContainerGap(524, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(23, 23, 23)
                .add(jLabel1)
                .addContainerGap(387, Short.MAX_VALUE))
        );

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jTextPane1.setName("jTextPane1"); // NOI18N
        jScrollPane2.setViewportView(jTextPane1);

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jPanel2.setEnabled(false);
        jPanel2.setName("jPanel2"); // NOI18N

        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setEnabled(false);
        jButton2.setName("jButton2"); // NOI18N
        jButton2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jButton2KeyPressed(evt);
            }
        });
        jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton2MouseClicked(evt);
            }
        });

        jTextField1.setText(resourceMap.getString("jTextField1.text")); // NOI18N
        jTextField1.setEnabled(false);
        jTextField1.setName("jTextField1"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setEnabled(false);
        jLabel3.setFocusable(false);
        jLabel3.setName("jLabel3"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(testgen4jsemiautomatico.Testgen4JSemiAutomaticoApp.class).getContext().getActionMap(Testgen4JSemiAutomaticoView.class, this);
        jButton3.setAction(actionMap.get("showAboutBox")); // NOI18N
        jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N
        jButton3.setEnabled(false);
        jButton3.setName("jButton3"); // NOI18N
        jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton3MouseClicked(evt);
            }
        });

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setEnabled(false);
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setEnabled(false);
        jLabel6.setName("jLabel6"); // NOI18N

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(15, 15, 15)
                        .add(jButton3)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jButton2)
                        .add(31, 31, 31)
                        .add(jLabel3)
                        .add(18, 18, 18)
                        .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 146, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(298, 298, 298)
                        .add(jLabel5)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel6)))
                .addContainerGap(368, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(20, Short.MAX_VALUE)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel5)
                    .add(jLabel6))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jButton2)
                    .add(jButton3)
                    .add(jLabel3))
                .add(20, 20, 20))
        );

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        jList1.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "No contiene Casos" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jList1.setName("jList1"); // NOI18N
        jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jList1ValueChanged(evt);
            }
        });
        jScrollPane3.setViewportView(jList1);

        jLabel4.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel4.setName("jLabel4"); // NOI18N

        org.jdesktop.layout.GroupLayout mainPanelLayout = new org.jdesktop.layout.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(mainPanelLayout.createSequentialGroup()
                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(mainPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .add(jButton1))
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 207, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(mainPanelLayout.createSequentialGroup()
                        .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .add(mainPanelLayout.createSequentialGroup()
                        .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(jLabel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE))
                        .addContainerGap())
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 786, Short.MAX_VALUE)
                    .add(mainPanelLayout.createSequentialGroup()
                        .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 72, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(mainPanelLayout.createSequentialGroup()
                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(mainPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(mainPanelLayout.createSequentialGroup()
                                .add(jLabel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 399, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .add(6, 6, 6)
                        .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(12, 12, 12)
                        .add(jLabel2)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(org.jdesktop.layout.GroupLayout.LEADING, mainPanelLayout.createSequentialGroup()
                        .add(jButton1)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 607, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusPanel.setName("statusPanel"); // NOI18N

        statusPanelSeparator.setName("statusPanelSeparator"); // NOI18N

        statusMessageLabel.setName("statusMessageLabel"); // NOI18N

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        statusAnimationLabel.setName("statusAnimationLabel"); // NOI18N

        progressBar.setName("progressBar"); // NOI18N

        org.jdesktop.layout.GroupLayout statusPanelLayout = new org.jdesktop.layout.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(statusPanelSeparator, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 999, Short.MAX_VALUE)
            .add(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(statusMessageLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 875, Short.MAX_VALUE)
                .add(progressBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(statusPanelLayout.createSequentialGroup()
                .add(statusPanelSeparator, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(statusMessageLabel)
                    .add(statusAnimationLabel)
                    .add(progressBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(3, 3, 3))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);
    }// </editor-fold>//GEN-END:initComponents
/**
 * Carga el archivo para armar el Arbol
 * @param evt
 */
    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
        UtilTestGen util=new UtilTestGen();
        String loadFine=util.loadFile(new Frame(), "java", "", ".CLASS");
        try {
           habilitarJpanel2(false);
            System.out.println("Veamos ..........:"+loadFine);

		util.ejecutarBatComp(loadFine);
		TreeTesis tree= new TreeTesis();
                jTree1.setVisible(false);
                jTree1.setModel(tree.TreeTesis("E:\\TESIS\\Repositorio\\data.xml").getModel());
                dtoListClass=tree.getDtoList();
                jTree1.setVisible(true);
           
                String patch= UtilTestGen.parserPatch(loadFine);
                Iterator<DtoXmlTree> it=dtoListClass.iterator();
                while(it.hasNext()){
                    DtoXmlTree dto=it.next();
                    dto.setPatch(patch);
                }

                System.out.println("Veamos ..........patch:"+patch);
		} catch (IOException e) {
			 System.out.println("Error de entrada Salida...: "+e);
			e.printStackTrace();

		} catch (JDOMException e1){
                    System.out.println("Error de entrada Salida...: "+e1);
                    e1.printStackTrace();
                } catch (Exception e2){
                     System.out.println("Error parser patch...: "+e2);
                    e2.printStackTrace();
                }
    }//GEN-LAST:event_jButton1MouseClicked

    private void jTree1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTree1MouseClicked


    }//GEN-LAST:event_jTree1MouseClicked

    private void jTree1ValueChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_jTree1ValueChanged
        class ayuda {

            private void jTree1ValueChanged(TreeSelectionEvent evt) {
                System.out.println("jTree1.valueChanged, event=" + evt);
                JLabel jLabel2;
                jLabel2 = new JLabel();
                jLabel2.setText("Clase: ");
                jLabel2.setBounds(194, 32, 74, 14);

            }
        }
        jPanel1.setVisible(false);
        Component[] contido = jPanel1.getComponents();
        if (evt.getNewLeadSelectionPath().getPath().length > 2) {
            this.removeField(contido);

            ayuda a = new ayuda();
            a.jTree1ValueChanged(evt);

            Object[] ver = evt.getNewLeadSelectionPath().getPath();
            String clase = ver[1].toString();
            String metodo = ver[2].toString();
            HashMap<String, HashMap<String, String>> parameTipohash;
            HashMap<String, String> parameTipo;
            HashMap<String, String> retornoTipo;
            String patch = "";
            DtoXmlTree dtotree = null;
            //saco el dto de la clase y metodo seleccionado
            for (DtoXmlTree dto : dtoListClass) {
                if (dto.getClassName().equals(clase)) {
                    dtotree = dto;
                }
            }
            retornoTipo = dtotree.getParameRetorno();
            parameTipohash = dtotree.getParameTipo();
            parameTipo = parameTipohash.get(metodo);
            Set<String> itpara = parameTipo.keySet();
            patch = dtotree.getPatch();
            int i = 2;
            for (String it : itpara) {
                String name = it;
                String tipo = parameTipo.get(it);
                name = "Parametro: " + name;
                JLabel namel = new JLabel(name);
                namel.setBounds(94, 16, 274, 180 + i * 80);

                jPanel1.add(namel);
                JLabel tipol = new JLabel("Tipo: " + tipo);
                tipol.setBounds(94, 16, 274, 210 + i * 80);
                JFormattedTextField input = UtilTestGen.getFormatotype(tipo);
                input.setBounds(190, 60 + 120 * (i + 1) / 3, 97, 20);
                jPanel1.add(tipol);
                jPanel1.add(input);
                i++;
            }
            Component dtoCaso = new DtoXMLCasoPrueba();
            ((DtoXMLCasoPrueba) dtoCaso).setClaseName(clase);
            ((DtoXMLCasoPrueba) dtoCaso).setMetodo(metodo);
            ((DtoXMLCasoPrueba) dtoCaso).setParameTipo(parameTipo);
            ((DtoXMLCasoPrueba) dtoCaso).setValorassert(retornoTipo.get(metodo));
            ((DtoXMLCasoPrueba) dtoCaso).setPatch(patch);
            jPanel1.remove(dtoCaso);
            jPanel1.add("dtoCaso", dtoCaso);
            ListarCasos listarCasos = new ListarCasos();
            DefaultListModel listarcaso = new DefaultListModel();
            System.out.println("Cantidad.....Casos:" + jList1.getModel().getSize());
            if (jList1.getModel().getSize() < 2) {
                for (DtoXMLCasoPrueba it : listarCasos.getcasos(clase, patch)) {
                    System.out.println("Lstando.....Casos:" + it);
                    listarcaso.addElement(it);
                }
                jList1.setModel(listarcaso);
            }

            System.out.println("Clase name:" + clase);
            System.out.println("Metodo name:" + metodo);
            System.out.println("Metodos name:" + parameTipo);
            System.out.println("Clase patch:" + patch);

            JLabel claseL = new JLabel("Class: " + clase);
            claseL.setBounds(190, 16, 200, 140);
            JLabel metodoL = new JLabel("Metodo: " + metodo);
            metodoL.setBounds(190, 16, 200, 180);
            jPanel1.add(claseL);
            jPanel1.add(metodoL);
            habilitarJpanel2(true);
            jLabel6.setText(retornoTipo.get(metodo));
            jTextField1.setText("");
            //jTextField1 = UtilTestGen.getFormatotype(retornoTipo.get(metodo));
           


        }
        jPanel1.setVisible(true);
    }//GEN-LAST:event_jTree1ValueChanged
private void habilitarJpanel2(boolean bb){
    jTextField1.setEnabled(bb);
    jTextField1.setEditable(bb);
    jLabel5.setEnabled(bb);
    jLabel6.setEnabled(bb);
    jLabel3.setEnabled(bb);
    jButton3.setEnabled(bb);
    jButton2.setEnabled(bb);

}

    private void jButton2KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jButton2KeyPressed
       
    }//GEN-LAST:event_jButton2KeyPressed

    private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
        //Recorro los componentes del Panel de valores
                 GenerarXML gxml=new GenerarXML();
                 this.generaDTOData();
                 Document doc=gxml.generarCasoXML(dtoCaso);
                 String patch=dtoCaso.getPatch()+dtoCaso.getClaseName()+dtoCaso.getMetodo();
                 gxml.storeXML(doc,patch );
    }//GEN-LAST:event_jButton2MouseClicked
    private  DtoXMLCasoPrueba generaDTOData(){ Component[] jDesk=this.jPanel1.getComponents();
		HashMap<String, String> paramValor=new HashMap<String, String>();
		int j=1;
		for(int i=0;i<jDesk.length;i++){
			if(jDesk[i].getClass().getName().equals("testgen4jsemiautomatico.DtoXMLCasoPrueba")){
				setDtoCaso((DtoXMLCasoPrueba) jDesk[i]);
			}
			if(jDesk[i].getClass().getName().equals("javax.swing.JTextField")){
				JTextField jtext=new JTextField();
				jtext=(JTextField) jDesk[i];
				System.out.println("Valor :"+jtext.getText().trim());
				paramValor.put("var"+String.valueOf(j), jtext.getText().trim());
				j++;
			}
			System.out.println(jDesk[i].getClass().getName());

		}
		dtoCaso.setParameValor(paramValor);
                	Set<String> clave=dtoCaso.getParameValor().keySet();
		for(String ind:clave){
			System.out.println("clave:"+ind);
			System.out.println("valor:"+paramValor.get(ind));
		}
		clave=dtoCaso.getParameTipo().keySet();
		for(String ind:clave){
			System.out.println("clave:"+ind);
			System.out.println("tipo:"+dtoCaso.getParameTipo().get(ind));
		}
                 Component[] jDeskAssert=this.jPanel2.getComponents();
                 for(int i=0;i<jDeskAssert.length;i++){
			if(jDeskAssert[i].getClass().getName().equals("javax.swing.JTextField")){
                            JTextField jtext=(JTextField) jDeskAssert[i];
				//System.out.println("Valor_____.................:"+jtext.getText());
                                dtoCaso.setTypeassert(jLabel6.getText());
                                dtoCaso.setValorassert(jtext.getText());
			}
                        }
                 return  dtoCaso;
    }
    private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList1ValueChanged
        class ayuda{
                private void jList1ValueChanged(ListSelectionEvent evt) {
		System.out.println("jTree1.valueChanged, event="+evt);
		JLabel jLabel2;
		jLabel2 = new JLabel();
		jLabel2.setText("Clase: ");
		jLabel2.setBounds(194, 32, 74, 14);

            }
        }
        jPanel1.setVisible(false);
        Component[] contido=jPanel1.getComponents();
				this.removeField(contido);
                                ayuda a=new ayuda();
				a.jList1ValueChanged(evt);

				Object[] ver=jList1.getSelectedValues();
                                System.out.println("Lista..... 1: "+ver[0]);
                                DtoXMLCasoPrueba dto=(DtoXMLCasoPrueba)ver[0];
				String clase=dto.getClaseName();
				String metodo=dto.getMetodo();
				HashMap<String, String> parameTipohash;
                            
                                String patch="";
                              
                               // retornoTipo=dto.getParameTipo();
                                parameTipohash=dto.getParameTipo();

                                Set<String> itpara=parameTipohash.keySet();
                                patch=dto.getPatch();
                                int i=2;
				for(String it:itpara){
					String name=it;
					String tipo=parameTipohash.get(it);
					name="Parametro: "+name;
					JLabel namel=new JLabel(name);
					namel.setBounds(94, 16, 274, 180+i*80);

					jPanel1.add(namel);
					JLabel tipol=new JLabel("Tipo: "+tipo);
					tipol.setBounds(94, 16, 274, 210+i*80);
					JFormattedTextField input=new JFormattedTextField(dto.getParameValor().get(it));
					input.setBounds(190,10+120*(i+1)/2, 97,20);
                                        input.setEditable(false);
					jPanel1.add(tipol);
					jPanel1.add(input);
                                        i++;
				}
				Component dtoCaso=dto;
                                jPanel1.remove(dtoCaso);
				jPanel1.add("dtoCaso",dtoCaso);
				System.out.println("Clase name:"+clase);
				System.out.println("Metodo name:"+metodo);
                                System.out.println("Clase patch:"+patch);

				JLabel claseL=new JLabel("Clase name: "+clase);
				claseL.setBounds(294, 16, 200, 140);
				JLabel metodoL=new JLabel("Metodo name: "+metodo);
				metodoL.setBounds(294,16,200,180);
				jPanel1.add(claseL);
				jPanel1.add(metodoL);

			  jPanel1.setVisible(true);
                          jLabel6.setText(dto.getTypeassert());
                          jTextField1.setText(dto.getValorassert());
                          jTextField1.setEditable(false);
                          jButton2.setEnabled(false);
                         
                          
    }//GEN-LAST:event_jList1ValueChanged

    private void jButton3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton3MouseClicked
                 GenerarXML gxml=new GenerarXML();
                 this.generaDTOData();
                 Document doc=gxml.generarCasoXML(dtoCaso);
                 gxml.storeXML(doc, "E:\\TESIS\\Repositorio\\data");
                 UtilTestGen.ejecutarBatRun(dtoCaso.getPatch());


    }//GEN-LAST:event_jButton3MouseClicked
private void resultadoCorrida(){
    
}
private void removeField(Component[] contido){
    for (Component it : contido) {
        if ("javax.swing.JLabel".equals(it.getClass().getName())) {
            jPanel1.remove(it);
        }
        if ("javax.swing.JFormattedTextField".equals(it.getClass().getName())) {
            jPanel1.remove(it);
        }
        if ("testgen4jsemiautomatico.DtoXMLCasoPrueba".equals(it.getClass().getName())) {
            jPanel1.remove(it);
        }
    }
}
    public DtoXMLCasoPrueba getDtoCaso() {
		return dtoCaso;
	}

	public void setDtoCaso(DtoXMLCasoPrueba dtoCaso) {
		this.dtoCaso = dtoCaso;
	}
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JList jList1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextPane jTextPane1;
    private javax.swing.JTree jTree1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    // End of variables declaration//GEN-END:variables
    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;
    private JDialog aboutBox;
}
